{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport canUseDom from \"rc-util/es/Dom/canUseDom\";\nimport OrderContext from \"./Context\";\nvar EMPTY_LIST = [];\n/**\n * Will add `div` to document. Nest call will keep order\n * @param render Render DOM in document\n */\n\nexport default function useDom(render, debug) {\n  var _React$useState = React.useState(function () {\n      if (!canUseDom()) {\n        return null;\n      }\n      var defaultEle = document.createElement('div');\n      if (process.env.NODE_ENV !== 'production' && debug) {\n        defaultEle.setAttribute('data-debug', debug);\n      }\n      return defaultEle;\n    }),\n    _React$useState2 = _slicedToArray(_React$useState, 1),\n    ele = _React$useState2[0]; // ========================== Order ==========================\n\n  var appendedRef = React.useRef(false);\n  var queueCreate = React.useContext(OrderContext);\n  var _React$useState3 = React.useState(EMPTY_LIST),\n    _React$useState4 = _slicedToArray(_React$useState3, 2),\n    queue = _React$useState4[0],\n    setQueue = _React$useState4[1];\n  var mergedQueueCreate = queueCreate || (appendedRef.current ? undefined : function (appendFn) {\n    setQueue(function (origin) {\n      var newQueue = [appendFn].concat(_toConsumableArray(origin));\n      return newQueue;\n    });\n  }); // =========================== DOM ===========================\n\n  function append() {\n    if (!ele.parentElement) {\n      document.body.appendChild(ele);\n    }\n    appendedRef.current = true;\n  }\n  function cleanup() {\n    var _ele$parentElement;\n    (_ele$parentElement = ele.parentElement) === null || _ele$parentElement === void 0 ? void 0 : _ele$parentElement.removeChild(ele);\n    appendedRef.current = false;\n  }\n  useLayoutEffect(function () {\n    if (render) {\n      if (queueCreate) {\n        queueCreate(append);\n      } else {\n        append();\n      }\n    } else {\n      cleanup();\n    }\n    return cleanup;\n  }, [render]);\n  useLayoutEffect(function () {\n    if (queue.length) {\n      queue.forEach(function (appendFn) {\n        return appendFn();\n      });\n      setQueue(EMPTY_LIST);\n    }\n  }, [queue]);\n  return [ele, mergedQueueCreate];\n}","map":{"version":3,"names":["_toConsumableArray","_slicedToArray","React","useLayoutEffect","canUseDom","OrderContext","EMPTY_LIST","useDom","render","debug","_React$useState","useState","defaultEle","document","createElement","process","env","NODE_ENV","setAttribute","_React$useState2","ele","appendedRef","useRef","queueCreate","useContext","_React$useState3","_React$useState4","queue","setQueue","mergedQueueCreate","current","undefined","appendFn","origin","newQueue","concat","append","parentElement","body","appendChild","cleanup","_ele$parentElement","removeChild","length","forEach"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@rc-component/portal/es/useDom.js"],"sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport canUseDom from \"rc-util/es/Dom/canUseDom\";\nimport OrderContext from \"./Context\";\nvar EMPTY_LIST = [];\n/**\n * Will add `div` to document. Nest call will keep order\n * @param render Render DOM in document\n */\n\nexport default function useDom(render, debug) {\n  var _React$useState = React.useState(function () {\n    if (!canUseDom()) {\n      return null;\n    }\n\n    var defaultEle = document.createElement('div');\n\n    if (process.env.NODE_ENV !== 'production' && debug) {\n      defaultEle.setAttribute('data-debug', debug);\n    }\n\n    return defaultEle;\n  }),\n      _React$useState2 = _slicedToArray(_React$useState, 1),\n      ele = _React$useState2[0]; // ========================== Order ==========================\n\n\n  var appendedRef = React.useRef(false);\n  var queueCreate = React.useContext(OrderContext);\n\n  var _React$useState3 = React.useState(EMPTY_LIST),\n      _React$useState4 = _slicedToArray(_React$useState3, 2),\n      queue = _React$useState4[0],\n      setQueue = _React$useState4[1];\n\n  var mergedQueueCreate = queueCreate || (appendedRef.current ? undefined : function (appendFn) {\n    setQueue(function (origin) {\n      var newQueue = [appendFn].concat(_toConsumableArray(origin));\n      return newQueue;\n    });\n  }); // =========================== DOM ===========================\n\n  function append() {\n    if (!ele.parentElement) {\n      document.body.appendChild(ele);\n    }\n\n    appendedRef.current = true;\n  }\n\n  function cleanup() {\n    var _ele$parentElement;\n\n    (_ele$parentElement = ele.parentElement) === null || _ele$parentElement === void 0 ? void 0 : _ele$parentElement.removeChild(ele);\n    appendedRef.current = false;\n  }\n\n  useLayoutEffect(function () {\n    if (render) {\n      if (queueCreate) {\n        queueCreate(append);\n      } else {\n        append();\n      }\n    } else {\n      cleanup();\n    }\n\n    return cleanup;\n  }, [render]);\n  useLayoutEffect(function () {\n    if (queue.length) {\n      queue.forEach(function (appendFn) {\n        return appendFn();\n      });\n      setQueue(EMPTY_LIST);\n    }\n  }, [queue]);\n  return [ele, mergedQueueCreate];\n}"],"mappings":"AAAA,OAAOA,kBAAkB,MAAM,8CAA8C;AAC7E,OAAOC,cAAc,MAAM,0CAA0C;AACrE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAOC,eAAe,MAAM,kCAAkC;AAC9D,OAAOC,SAAS,MAAM,0BAA0B;AAChD,OAAOC,YAAY,MAAM,WAAW;AACpC,IAAIC,UAAU,GAAG,EAAE;AACnB;AACA;AACA;AACA;;AAEA,eAAe,SAASC,MAAM,CAACC,MAAM,EAAEC,KAAK,EAAE;EAC5C,IAAIC,eAAe,GAAGR,KAAK,CAACS,QAAQ,CAAC,YAAY;MAC/C,IAAI,CAACP,SAAS,EAAE,EAAE;QAChB,OAAO,IAAI;MACb;MAEA,IAAIQ,UAAU,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;MAE9C,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAIR,KAAK,EAAE;QAClDG,UAAU,CAACM,YAAY,CAAC,YAAY,EAAET,KAAK,CAAC;MAC9C;MAEA,OAAOG,UAAU;IACnB,CAAC,CAAC;IACEO,gBAAgB,GAAGlB,cAAc,CAACS,eAAe,EAAE,CAAC,CAAC;IACrDU,GAAG,GAAGD,gBAAgB,CAAC,CAAC,CAAC,CA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